<template>
<section class="oa-form__table">
    <h5>{{approve.name}}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>
          {{ approve.name }}
          <span v-if="approve && approve.code">{{ approve.code }}</span>
        </td>
      </tr>
      <tr>
        <td>流程名称</td>
        <td>
          <span v-if="$route.query.from == 'new'">
            新建{{approve.name}}
          </span>
          <span v-else>
            {{approve.approve_name}}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <span v-if="$route.query.from === 'new'">{{ approve.name }}</span>
      <span v-else>
        {{ approve.approve_name }}
      </span>
    </h3>
    <table class="achievement__tab">
      <tr class="border_0">
        <td>考核周期:</td>
        <td>
          <el-date-picker
            value-format="yyyy-MM-dd"
            type="date"
            v-model="applyTime"
            :disabled="$route.query.from !== 'new'"
            placeholder="考核周期">
          </el-date-picker>
        </td>
        <td>部门:</td>
        <td>
          <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
            <el-option
              v-for="item in departments"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </td>
        <td>姓名:</td>
        <td>
          <el-select v-model="value" style="width:60%" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
            <el-option
              v-for="item in staff"
              :key="item.value"
              :label="item.label"
              :value="item">
            </el-option>
          </el-select>
        </td>
        <!-- <td>岗位:</td> -->
        <td>岗位:<span style="display:inline-block;width:100px;padding-left:10px;"><el-input v-model="gangwei" :disabled="$route.query.from !== 'new'" placeholder="岗位"/></span></td>
      </tr>
      <tr>
        <td class="_name">考核维度</td>
        <td class="_name">指标定义</td>
        <td class="_name">权重</td>
        <td class="_name" width="300">评分说明</td>
        <td class="_name">评定人</td>
        <td class="_name">自评</td>
        <td class="_name">得分</td>
      </tr>
      <tr>
        <td>办公系统</td>
        <td>系统运营</td>
        <td>30%</td>
        <td>公司网络、软件、硬件设备及OA系统发生故障或模块需要优化调整时，在接到<br />
        报修及调整信息后，半天内完成任务（<span class="c_red">超时--次扣2分</span>).</td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a160" :disabled="obj.a160Flag" /></td>
        <td><el-input v-model="obj.a167" :disabled="obj.a167Flag" /></td>
      </tr>
      <tr>
        <td rowspan="3">信息系统</td>
        <td>小程序运维</td>
        <td>30%</td>
        <td>小程序收到功能优化调整7天内完成开发（<span class="c_red">超时1次扣2分</span>)<br />
        确保小程序访问人数较上月增长30个以上（<span class="c_red">增长未达标1次扣3分</span>)</td>
        <td>直属上级</td>
         <td><el-input v-model="obj.a161" :disabled="obj.a161Flag" /></td>
        <td><el-input v-model="obj.a168" :disabled="obj.a168Flag" /></td>
      </tr>
      <tr>
        <td>SEO网站优化</td>
        <td>20%</td>
        <td>根据公司业务需要建立营销型网站，进行搜索关键词优化引流。保证天艺媒体搜<br />
        索排名前三（<span class="c_red">掉排名检查到1次扣2分</span>)</td>
        <td>直属上级</td>
         <td><el-input v-model="obj.a162" :disabled="obj.a162Flag" /></td>
        <td><el-input v-model="obj.a169" :disabled="obj.a169Flag" /></td>
      </tr>
      <tr>
        <td>平台运营</td>
        <td>10%</td>
        <td>公司网站每月10日前更新-条行业信息、公众号每周五做排版发布（<span class="c_red">超时--次扣<br />
        2分</span>)</td>
        <td>品牌部</td>
         <td><el-input v-model="obj.a163" :disabled="obj.a163Flag" /></td>
        <td><el-input v-model="obj.a170" :disabled="obj.a170Flag" /></td>
      </tr>
      <tr>
        <td>公司制度</td>
        <td>遵守公司规章制度</td>
        <td>10%</td>
        <td>对公司制度及企业文化的理解和执行:履行本部门工作中的行为表现。</td>
        <td>直属上级</td>
        <td><el-input v-model="obj.a164" :disabled="obj.a164Flag" /></td>
        <td><el-input v-model="obj.a171" :disabled="obj.a171Flag" /></td>
      </tr>
      <tr>
        <td rowspan="2">加分项</td>
        <td>增量工作内容</td>
        <td>&nbsp;</td>
        <td>超出岗位职责范围、领导交办较为繁杂的事务、工作表现卓越等</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a165" :disabled="obj.a165Flag" /></td>
        <td><el-input v-model="obj.a678" :disabled="obj.a678Flag" /></td>
      </tr>
      <tr>
        <td>对公司的建议</td>
        <td>&nbsp;</td>
        <td>对市场拓展、业务销告、内部管理等建设性意见</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a166" :disabled="obj.a166Flag" /></td>
        <td><el-input v-model="obj.a679" :disabled="obj.a679Flag" /></td>
      </tr>
      <tr>
        <td colspan="3">自评:{{myScore}}</td>
        <td colspan="5">综合考核率:{{otherScore}}</td>
      </tr>
    </table>
    <history :process="process"></history>
    <files></files>
  </section>
</template>
<script>
import mixin from '@/mixins/index.js'
import history from '../service/components/process'
import files from '../service/components/files'
import { sum } from '@/utils/domUtils.js'
// import { save, info, getAutoKey } from '@/api/oa/index.js'
const obj = {}
for (let i = 160; i <= 173; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
for (let i = 678; i <= 679; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
export default {
  mixins: [mixin],
  data () {
    return {
      reason: '',
      truename: '',
      department: '',
      flag: false,
      value: '',
      obj: JSON.parse(JSON.stringify(obj)),
      applyTime: '',
      gangwei: '',
      file_paths: [],
      file_names: [],
      field_ids: [],
      field_vals: [],
      autoField: []
    }
  },
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'addDofield', 'departments', 'process'],
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    },
    myScore () {
      const result = []
      for (let i = 160; i <= 166; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    },
    otherScore () {
      const result = []
      for (let i = 167; i <= 173; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      result.push(this.obj.a678)
      result.push(this.obj.a679)
      return sum(result)
    }
  },
  watch: {
    addDofield () {
      this.addDofieldRender()
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.obj = JSON.parse(JSON.stringify(obj))
      if (this.$route.query.from === 'new') {
        this.disabled = true
      } else {
        this.infoFunc()
      }
    })
  },
  methods: {
  }
}
</script>
